home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 262 / DPCS1209.ISO / Assets / Interface / Main.dxr / Flash Components_1_Centre pane.swf / scripts / __Packages / HighlightBoxout.as < prev    next >
Encoding:
Text File  |  2005-05-18  |  7.9 KB  |  251 lines

  1. class HighlightBoxout extends MovieClip
  2. {
  3.    var __progress;
  4.    var background;
  5.    var __target;
  6.    var __title;
  7.    var __titleText;
  8.    var __desc;
  9.    var __bgWidth;
  10.    var __bgHeight;
  11.    var onRollOver;
  12.    var boxoutBorder;
  13.    var onRollOut;
  14.    var onPress;
  15.    var dispatchEvent;
  16.    static var symbolName = "HighlightBoxout";
  17.    static var symbolOwner = HighlightBoxout;
  18.    var className = "HighlightBoxout";
  19.    static var version = "0.0.0.1";
  20.    function HighlightBoxout()
  21.    {
  22.       super();
  23.       mx.events.EventDispatcher.initialize(this);
  24.    }
  25.    function init(Void)
  26.    {
  27.       this.__progress = new mx.controls.ProgressBar();
  28.       this.__progress.label = "Highlight information will appear here";
  29.       this.__progress.labelPlacement = "bottom";
  30.       this.__progress.mode = "manual";
  31.       super.init();
  32.    }
  33.    function size(Void)
  34.    {
  35.       super.size();
  36.    }
  37.    function get height()
  38.    {
  39.       return this.background._height;
  40.    }
  41.    function set target(tgt)
  42.    {
  43.       this.__target = tgt;
  44.    }
  45.    function set title(titleText)
  46.    {
  47.       trace("HighlightBoxout received title: " + titleText);
  48.       this.__title = this.attachMovie("TextArea","title",3);
  49.       this.__title.hScrollPolicy = this.__title.vScrollPolicy = "off";
  50.       this.__title.label.selectable = this.__title.editable = this.__title.wordWrap = false;
  51.       this.__title._x = 10;
  52.       this.__title._y = 5;
  53.       this.__title.setSize(340,32);
  54.       this.__title.html = true;
  55.       this.__title.setStyle("styleName","boxTitleStyle");
  56.       this.__title.styleSheet = _global.textStyles;
  57.       this.__title.embedFonts = true;
  58.       this.__titleText = this.removeHTMLTags(titleText);
  59.       this.__title.text = "<boxtitle>" + this.__titleText + "</boxtitle>";
  60.       trace("TITLE HEIGHT: " + this.__title._height);
  61.    }
  62.    function set desc(descText)
  63.    {
  64.       this.__desc = this.attachMovie("TextArea","desc",5);
  65.       this.__desc._x = 10;
  66.       this.__desc._y = 36;
  67.       this.__desc.setSize(340,85);
  68.       this.__desc.html = true;
  69.       this.__desc.hScrollPolicy = this.__desc.vScrollPolicy = "off";
  70.       this.__desc.label.selectable = this.__desc.editable = false;
  71.       this.__desc.wordWrap = true;
  72.       this.__desc.embedFonts = true;
  73.       this.__desc.setStyle("styleName","boxDescStyle");
  74.       this.__desc.styleSheet = _global.textStyles;
  75.       this.__desc.text = "<boxdesc>" + descText + "</boxdesc>";
  76.    }
  77.    function set styleSheet(css)
  78.    {
  79.       this.__title.styleSheet = this.__desc.styleSheet = css;
  80.    }
  81.    function set enabled(activeStatus)
  82.    {
  83.       if(activeStatus == true)
  84.       {
  85.          var _loc2_ = new TextFormat();
  86.          _loc2_.color = 0;
  87.          var _loc4_ = "<headline>" + this.__title.htmlText.slice(18,this.__title.htmlText.length - 19) + "</headline>";
  88.          this.__title.setTextFormat(_loc2_);
  89.          this.__title.setNewTextFormat(_loc2_);
  90.          this.__title.htmlText = _loc4_;
  91.          this.drawBackground(true,this.__bgWidth,this.__bgHeight);
  92.          this.onRollOver = function()
  93.          {
  94.             this.__title.text = "<boxtitle><a class=\'underlined\'>" + this.__titleText + "</a></boxtitle>";
  95.             var _loc2_ = new Color(this.boxoutBorder);
  96.             _loc2_.setRGB("0x005BAB");
  97.          };
  98.          this.onRollOut = function()
  99.          {
  100.             this.__title.text = "<boxtitle>" + this.__titleText + "</boxtitle>";
  101.             var _loc2_ = new Color(this.boxoutBorder);
  102.             _loc2_.setRGB("0x444444");
  103.          };
  104.          this.onPress = function()
  105.          {
  106.             this.__title.text = "<boxtitle>" + this.__titleText + "</boxtitle>";
  107.             var _loc2_ = new Color(this.boxoutBorder);
  108.             _loc2_.setRGB("0x444444");
  109.             this.sendMessage("Highlight pressed");
  110.          };
  111.       }
  112.       else
  113.       {
  114.          _loc2_ = new TextFormat();
  115.          _loc2_.color = 8421504;
  116.          _loc4_ = "<headlinedisabled>" + this.__title.htmlText.slice(10,this.__title.htmlText.length - 11) + "</headlinedisabled>";
  117.          this.__title.setTextFormat(_loc2_);
  118.          this.__title.setNewTextFormat(_loc2_);
  119.          this.__title.htmlText = _loc4_;
  120.          this.drawBackground(false,this.__bgWidth,this.__bgHeight);
  121.          this.onRollOver = this.onRollOut = this.onPress = null;
  122.       }
  123.       this.__desc.label.selectable = false;
  124.       this.__title.enabled = this.__desc.enabled = activeStatus;
  125.    }
  126.    function drawBackground(enable, w, h)
  127.    {
  128.       trace("in drawBackground");
  129.       trace(this);
  130.       if(enable)
  131.       {
  132.          trace("enabled");
  133.          var lightCol = 16776140;
  134.          var darkCol = 4473924;
  135.       }
  136.       else
  137.       {
  138.          trace("disabled");
  139.          var lightCol = 15658734;
  140.          var darkCol = 14540253;
  141.       }
  142.       var borderWidth = 1;
  143.       this.createEmptyMovieClip("background",1);
  144.       trace(this.background);
  145.       with(this.background)
  146.       {
  147.          moveTo(borderWidth,0);
  148.          beginFill(lightCol,100);
  149.          lineTo(w - borderWidth,0);
  150.          lineTo(w - borderWidth,h - borderWidth);
  151.          lineTo(borderWidth,h - borderWidth);
  152.          lineTo(borderWidth,borderWidth);
  153.          endFill();
  154.       }
  155.       this.createEmptyMovieClip("boxoutBorder",2);
  156.       trace(this.boxoutBorder);
  157.       with(this.boxoutBorder)
  158.       {
  159.          lineStyle(borderWidth,darkCol,40);
  160.          moveTo(0,0);
  161.          lineTo(w,0);
  162.          lineTo(w,h);
  163.          lineTo(0,h);
  164.          lineTo(0,0);
  165.          lineStyle(borderWidth,darkCol,100);
  166.          moveTo(1,1);
  167.          lineTo(w - 1,1);
  168.          lineTo(w - 1,h - 1);
  169.          lineTo(1,h - 1);
  170.          lineTo(1,1);
  171.       }
  172.    }
  173.    function setSize(w, h)
  174.    {
  175.       this.__bgHeight = h;
  176.       this.__bgWidth = w;
  177.       this.drawBackground(true,w,h);
  178.    }
  179.    function set image(imagePath)
  180.    {
  181.    }
  182.    function removeHTMLTags(htmlText)
  183.    {
  184.       var _loc6_ = function(txt, index)
  185.       {
  186.          return txt.indexOf("<",index);
  187.       };
  188.       var _loc8_ = function(txt, index)
  189.       {
  190.          return txt.indexOf(">",index);
  191.       };
  192.       var _loc2_ = new Array();
  193.       var _loc7_ = 0;
  194.       var _loc9_ = undefined;
  195.       var _loc10_ = undefined;
  196.       while(_loc7_ < htmlText.length)
  197.       {
  198.          _loc9_ = _loc6_(htmlText,_loc7_);
  199.          if(_loc9_ == -1)
  200.          {
  201.             break;
  202.          }
  203.          _loc10_ = _loc8_(htmlText,_loc9_);
  204.          var _loc3_ = _loc6_(htmlText,_loc10_);
  205.          while(_loc3_ == _loc10_ + 1)
  206.          {
  207.             _loc10_ = _loc8_(htmlText,_loc3_);
  208.             _loc3_ = _loc6_(htmlText,_loc10_);
  209.          }
  210.          _loc2_.push({start:_loc9_,end:_loc10_});
  211.          _loc7_ = _loc10_ + 1;
  212.       }
  213.       var _loc5_ = 0;
  214.       while(_loc5_ < _loc2_.length)
  215.       {
  216.          _loc9_ = _loc2_[_loc5_].start;
  217.          var _loc11_ = htmlText.charAt(_loc2_[_loc5_].start);
  218.          _loc10_ = _loc2_[_loc5_].end;
  219.          var _loc12_ = htmlText.charAt(_loc2_[_loc5_].end);
  220.          var _loc16_ = htmlText.substring(_loc9_ + 1,_loc10_);
  221.          _loc5_ = _loc5_ + 1;
  222.       }
  223.       if(_loc2_.length != 0)
  224.       {
  225.          var _loc18_ = "";
  226.          if(_loc2_[0].start > 0)
  227.          {
  228.             _loc18_ += htmlText.substring(0,_loc2_[0].start);
  229.          }
  230.          var _loc4_ = 0;
  231.          while(_loc4_ < _loc2_.length - 1)
  232.          {
  233.             var _loc13_ = _loc2_[_loc4_].end + 1;
  234.             var _loc15_ = _loc2_[_loc4_ + 1].start;
  235.             _loc18_ += htmlText.substring(_loc2_[_loc4_].end + 1,_loc2_[_loc4_ + 1].start);
  236.             _loc4_ = _loc4_ + 1;
  237.          }
  238.          if(_loc2_[_loc2_.length - 1].end < htmlText.length - 1)
  239.          {
  240.             _loc18_ += htmlText.substring(_loc2_[_loc2_.length - 1].end + 1);
  241.          }
  242.          return _loc18_;
  243.       }
  244.       return htmlText;
  245.    }
  246.    function sendMessage(p_msgtxt)
  247.    {
  248.       this.dispatchEvent({target:this,type:"press",msgtxt:p_msgtxt});
  249.    }
  250. }
  251.